package com.kh.pajx.sop.service.bal.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.kh.pajx.sop.base.BaseServiceImpl;
import com.kh.pajx.sop.dao.bal.IBalBuMgrDriveDao;
import com.kh.pajx.sop.domain.bal.BalBuMgrDrive;
import com.kh.pajx.sop.service.bal.IBalBuMgrDriveService;
import com.kh.pajx.sop.util.page.QueryHelper;

@Service
@Transactional
public class BalBuMgrDriveServiceImpl extends BaseServiceImpl<BalBuMgrDrive> implements IBalBuMgrDriveService {
	
	@Resource
	private IBalBuMgrDriveDao balBuMgrDao;
	
	
	@Override
	public List<BalBuMgrDrive> findNewList() throws Exception{
		return balBuMgrDao.findList(0);
	}
	
	@Override
	public void showNewList(String deptCode, int pageNum, int pageSize) throws Exception{
		new QueryHelper(BalBuMgrDrive.class, "bal")
		.addCondition("bal.saleDeptId=?", deptCode)
		.addCondition("bal.billState=?", 0)
		.addOrderProperty("bal.ywEndDate", false)
		.addOrderProperty("bal.saleDeptId", true)
		.addOrderProperty("bal.areaName", true)
		.preparePageBean(balBuMgrDao, pageNum, pageSize);
	}
	
	
	
	// ==============================================
	@Override
	public BalBuMgrDrive getById(String uuid) {
		return balBuMgrDao.getById(uuid);
	}
	
	@Override
	public void findBuMgrHisByAreaCode(String areaCode, int pageNum, int numPerPage) throws Exception {
		new QueryHelper(BalBuMgrDrive.class, "bal")
		.addCondition("bal.areaCode=?", areaCode)
		.addOrderProperty("bal.ywEndDate", false)
		.addOrderProperty("bal.saleDeptId", true)
		.addOrderProperty("bal.areaName", true)
		.preparePageBean(balBuMgrDao, pageNum, numPerPage);
	}
	
	@Override
	public List<BalBuMgrDrive> findList(String billCode, int billState) throws Exception {
		return balBuMgrDao.findList(billCode, billState);
	}
	
}
